<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Gym Rat | Exercise List</title>
</head>
<body>
<jsp:include page="/includes/nav.jsp" />
<h1>Exercise List</h1>
<p>Select an exercise from the list to view further information. If
you are the creator of an exercise you may delete it from this list or
modify it when viewing additional information</p>
<br>
<a href="<c:url value='/exercise/create' />">+Create a New
Exercise.+</a>
<form action="delete" method="post">
<table width="100%">
	<tr class="tableHeader">
		<td><b><u>Exercise</u></b></td>
		<td><b><u>Muscle Group</u></b></td>
		<td><b><u>Variations</u></b></td>
		<td><b><u>Equipment</u></b></td>
		<td><b><u>Select</u></b></td>

	</tr>

	<c:forEach var="exercise" items="${exercises}" varStatus="status">
		<c:choose>
			<c:when test="${status.count % 2 == 1 }">
				<c:set var="rowClass" value="tableOddRow" />
			</c:when>
			<c:otherwise>
				<c:set var="rowClass" value="tableEvenRow" />
			</c:otherwise>
		</c:choose>
		<tr class="${rowClass}">
			<td><a
				href="<c:url value='/exercise/info?id=${exercise.id }' />">${exercise.name
			}</a></td>
			<td>${exercise.muscleGroup }</td>
			<td><c:forEach var="variation" items="${exercise.variations }">
					${variation.name}
				</c:forEach></td>
			<td><span style="max-width: 50px;"> <c:forEach
				var="equipment" items="${exercise.equipment }">
					${equipment.name}
				</c:forEach></span></td>
			<td><c:if
				test='${(exercise.custom == true) || (user.admin == true)}'>
				<input type="checkbox" name="deleteBox" value="${exercise.id }" />
			</c:if> <c:if test='${(exercise.custom == true)}'>
			*</c:if></td>
		</tr>
	</c:forEach>

	<jsp:useBean id="assignment3"
		class="com.emuporium.gymrat.server.data.Exercise" scope="session"/>
		<jsp:setProperty name="assignment3" property="name"
			value="But this should be visible" />
	<%--
	<tr>
		<td><jsp:getProperty name="assignment3" property="name" /></td>
		<%Cookie[] cookies = request.getCookies();
		for (Cookie c : cookies)
		{
			if (c.getName().equals("assignment3")){
		%>
		<td><%= c.getValue() %></td>
		
		<%} }%> --%>
	<tr>
		<td><jsp:getProperty name="assignment3" property="name" /></td>
	</tr>
	<tr>
		<td>${cookie["assignment3"].value }</td>
	</tr>
	<tr>
		<td colspan=5 align="right">*Custom Exercise</td>
	</tr>
	<tr>
		<td colspan=5 align="right"><input type="button" value="Delete"
			onClick="if(confirm('Really delete selected exercises?'))
	submit()"></td>
	</tr>
	<tr>
		<td colspan=5>
		<hr>
		</td>
</table>
</form>
<a href="<c:url value='/exercise/create' />">+Create a New Exercise+</a>
</body>
</html>